#include<stdio.h>
#include<string.h>
int main(int argc, char const *argv[])
{
    char buf[128];
    char filename[20];
    char choice;
    printf("please input filename:");
    scanf("%s",filename);
    //setbuf(stdin,NULL);
    FILE *fp = fopen(filename,"w+");
    if(fp == NULL)
    {
        perror("fopen() fail");
        return -1;
    }
    while(1)
    {
        while(getchar()!='\n');
        bzero(buf,128);
        printf("Input string:");
        fgets(buf,sizeof(buf),stdin);
        buf[strlen(buf)-1]='\0';
        //scanf("%s",buf);
        fprintf(fp,"%s",buf);
        
        printf("\nContinue:?\n");
        char c = getchar();
        if((c== 'n') || (c=='N'))
        {
            break;
        }
    }
    //fclose(fp);

    fseek(fp,0,SEEK_SET);
    char bf;
    while(1)
    {
        if(fscanf(fp,"%c",&bf)!=EOF)
        {
            if(bf>='a' && bf <='z'){
                printf("%c",bf-32);
            }else{
                printf("%c",bf);
            }
        }else{
            break;
        }
    }
    printf("\n");
    fclose(fp);
    return 0;
}
